package com.fuluwa.domain.usercenter.model.competence;

import java.util.List;

import com.fuluwa.domain.security.model.User;
import com.google.common.collect.Lists;



interface Computer {
	Computer add(Computer c);

	Computer plus(Computer c);

	float compute();
}

abstract class AbstractComputer implements Computer {

	@Override
	public Computer add(Computer c) {
		return new AddComputer(c, c);
	}

	@Override
	public Computer plus(Computer c) {
		return new PlusComputer(this, c);
	}
}

class AddComputer extends AbstractComputer {
	Computer c1;
	Computer c2;

	public AddComputer(Computer c1, Computer c2) {
		this.c1 = c1;
		this.c2 = c2;
	}

	@Override
	public float compute() {
		return c1.compute() + c2.compute();
	}

}

class PlusComputer extends AbstractComputer {
	Computer c1;
	Computer c2;

	public PlusComputer(Computer c1, Computer c2) {
		this.c1 = c1;
		this.c2 = c2;
	}

	@Override
	public float compute() {
		return c1.compute() * c2.compute();
	}
}

class Test extends AbstractComputer {

	@Override
	public float compute() {
		return 1;
	}

}
public class CompetenceScoreTest {

	public static void main(String[] args) {
		float compute = new Test().add(new Test()).compute();
		System.out.println(compute);
		
//		CompetenceCategory  category=new CompetenceCategory();
//		category.type=CompetenceType.GENERIC;
		
		List<CompetenceSubDefine> subScores=Lists.newArrayList();
//		CompetenceSubDefine score=new CompetenceSubDefine(new CompetenceSubType(CompetenceType.GENERIC,"Management Ability"),CompetenceScore.LESS_UNDERSTANDING);
//		CompetenceSubDefine score1=new CompetenceSubDefine(new CompetenceSubType(CompetenceType.GENERIC,"Comunicate Ability"),CompetenceScore.LITTLE);
//		subScores.add(score1);
//		subScores.add(score);
//		Competence genericCompetence = CompetenceType.GENERIC.getCompetence();
//		genericCompetence.addCompetenceSubCategoryDefineScore(score);
//		genericCompetence.addCompetenceSubCategoryDefineScore(score1);
//		System.out.println(CompetenceType.GENERIC.getCompetence().findAll());
//		System.out.println(CompetenceType.GENERIC.getCompetence().compute());
		
		UserCompetenceScore s = new UserCompetenceScore(new User((long) 1));
		s.updateGenericScore(4);
		s.updateHandWorkingScore(20);
		s.updateOrgImpactScore(30);
		s.updateProfessionScore(50);
		System.out.println(s.getMinScore());
		System.out.println(s.getMinCompetenceType());
		
		List<CompentenceLevel> compLvls=Lists.newArrayList();
		CompentenceLevel level1=new CompentenceLevel(1, CompetenceType.GENERIC, 5);
		CompentenceLevel level2=new CompentenceLevel(2, CompetenceType.GENERIC, 10);
		CompentenceLevel level3=new CompentenceLevel(3, CompetenceType.GENERIC, 20);
		CompentenceLevel level4=new CompentenceLevel(4, CompetenceType.GENERIC, 40);
		compLvls.add(level1);
		compLvls.add(level2);
		compLvls.add(level3);
		compLvls.add(level4);
		CompentenceLevel min = CompentenceLevelHelper.getMinCompentenceLevel(compLvls,s);
		System.out.println(min.getLevelValue());
		
		LevelAdditionDefine levelAddtion1=new LevelAdditionDefine(1, 0.05f);
		LevelAdditionDefine levelAddtion2=new LevelAdditionDefine(2, 0.10f);
		LevelAdditionDefine levelAddtion3=new LevelAdditionDefine(3, 0.13f);
		LevelAdditionDefine levelAddtion4=new LevelAdditionDefine(4, 0.15f);
		
		System.out.println(CompetenceType.GENERIC.compute(subScores, levelAddtion4));
	}

}
//lvl define,lvl1=1000,lvl2=2000
class LevelDefine {
	private Integer level;
	private Integer value;
}
class CompetenceBuilder{
	//define 4 competences and lvl adding percent
}